#自己的方法将部分数字字符串元素转换为int
def txt_read_dict(filename):
    with open(filename,'r') as file:
        str_list = file.read()
        new_list = str_list.split("\n")
        #['sjf_234 a 1 11', 'lj_675 b 2 22', 'zyj_423 c 3 33', 'wl_5281 d 4 44', 'ylj_119 e 5 55', 'ck-100 f 6 66']
    for i in range(len(new_list)):
        new_list[i] = new_list[i].split()  #将列表中的每一个大元素，再以‘ ’劈分开,组成一个个小列表 ['sjf_234', 'a', '1', '11']
    '''
    [['sjf_234', 'a', '1', '11'], ['lj_675', 'b', '2', '22'], ['zyj_423', 'c', '3', '33'], ['wl_5281', 'd', '4', '44'], ['ylj_119', 'e', '5', '55'], ['ck-100', 'f', '6', '66']]
    '''

    txt_dict={}
    for i in range(len(new_list)):
        for j in range(len(new_list[i])):
            if j==0:
                new_list[i].insert(0,i+1)
            continue
    for k in range(len(new_list)):
        txt_dict[new_list[k][0]] = [new_list[k][1],new_list[k][2],int(new_list[k][3]),int(new_list[k][4])]
    return txt_dict

txt_dict = txt_read_dict(r'C:/Users/ASUS~/Desktop/data2.txt')
print(txt_dict)
print(len(txt_dict))
print(len(txt_dict.get(1)))
print(txt_dict.get(3))
print(txt_dict.get(3)[0])
print(txt_dict.get(3)[1])
